package com.travelgroup.controller;

import com.travelgroup.domain.dto.RouteDTO;
import com.travelgroup.domain.entity.TourRoute;
import com.travelgroup.exception.R;
import com.travelgroup.service.ITourRouterService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/route")
@Tag(name = "路线模板模块")
public class RouteController {
    @Resource
    private ITourRouterService tourRouterService;

    @PostMapping("/create")
    @Operation(summary = "创建旅游路线")
    public R<Long> createTourRoute(@RequestBody RouteDTO routeDTO) {
        return tourRouterService.createTourRouter(routeDTO);
    }

    @GetMapping("/query/{id}")
    @Operation(summary = "根据id获取路线信息")
    public R<RouteDTO> queryTourRouteById(@PathVariable Long id) {
        return tourRouterService.queryTourRouteById(id);
    }

    @PutMapping("/update/{id}")
    @Operation(summary = "修改旅游路线")
    public R<RouteDTO> updateTourRoute(@PathVariable Long id, @RequestBody RouteDTO routeDTO) {
        return tourRouterService.updateTourRoute(id, routeDTO);
    }

    @DeleteMapping("/delete/{id}")
    @Operation(summary = "删除旅游路线")
    public R<?> deleteTourRoute(@PathVariable Long id) {
        return tourRouterService.deleteTourRoute(id);
    }

    @GetMapping("/query/user/{userId}")
    @Operation(summary = "查询用户创建的路线")
    public R<List<TourRoute>> queryTourRoutesByUserId(@PathVariable Long userId,
                                                      @RequestParam(defaultValue = "1") Integer current) {
        return tourRouterService.queryTourRoutesByUserId(userId, current);
    }


}
